package com.yunpuvip.sachet.controller;

import com.yunpuvip.sachet.biz.entity.BalanceHistory;
import com.yunpuvip.sachet.biz.model.params.BalanceHistoryParam;
import com.yunpuvip.sachet.biz.service.BalanceHistoryService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import com.yunpuvip.sachet.modular.page.LayuiPageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 余额变动历史控制器
 *
 * @author wushaohong
 * @Date 2019-08-10 09:46:09
 */
@Controller
@RequestMapping("/balanceHistory")
public class BalanceHistoryController extends BaseController {

    private String PREFIX = "/modular/balanceHistory";

    @Autowired
    private BalanceHistoryService balanceHistoryService;

    /**
     * 跳转到主页面
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/balanceHistory.html";
    }

    /**
     * 新增页面
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/balanceHistory_add.html";
    }

    /**
     * 编辑页面
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/balanceHistory_edit.html";
    }

    /**
     * 新增接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(BalanceHistoryParam balanceHistoryParam) {
        this.balanceHistoryService.add(balanceHistoryParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(BalanceHistoryParam balanceHistoryParam) {
        this.balanceHistoryService.update(balanceHistoryParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(BalanceHistoryParam balanceHistoryParam) {
        this.balanceHistoryService.delete(balanceHistoryParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(BalanceHistoryParam balanceHistoryParam) {
        BalanceHistory detail = this.balanceHistoryService.getById(balanceHistoryParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author wushaohong
     * @Date 2019-08-10
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(BalanceHistoryParam balanceHistoryParam) {
        return this.balanceHistoryService.findPageBySpec(balanceHistoryParam);
    }

}


